<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class IRB::Irb - irb: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../Object.html">Object</a>
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-build_statement">#build_statement</a>
    <li ><a href="#method-i-configure_io">#configure_io</a>
    <li ><a href="#method-i-convert_invalid_byte_sequence">#convert_invalid_byte_sequence</a>
    <li ><a href="#method-i-debug_break">#debug_break</a>
    <li ><a href="#method-i-debug_readline">#debug_readline</a>
    <li ><a href="#method-i-each_top_level_statement">#each_top_level_statement</a>
    <li ><a href="#method-i-encode_with_invalid_byte_sequence">#encode_with_invalid_byte_sequence</a>
    <li ><a href="#method-i-eval_input">#eval_input</a>
    <li ><a href="#method-i-handle_exception">#handle_exception</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-read_input">#read_input</a>
    <li ><a href="#method-i-readmultiline">#readmultiline</a>
    <li ><a href="#method-i-run">#run</a>
    <li ><a href="#method-i-signal_handle">#signal_handle</a>
    <li ><a href="#method-i-signal_status">#signal_status</a>
    <li ><a href="#method-i-single_line_command-3F">#single_line_command?</a>
    <li ><a href="#method-i-suspend_context">#suspend_context</a>
    <li ><a href="#method-i-suspend_input_method">#suspend_input_method</a>
    <li ><a href="#method-i-suspend_name">#suspend_name</a>
    <li ><a href="#method-i-suspend_workspace">#suspend_workspace</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-IRB::Irb">
    <h1 id="class-IRB::Irb" class="class">
      class IRB::Irb
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="CONTROL_CHARACTERS_PATTERN">CONTROL_CHARACTERS_PATTERN
          <dd>
          <dt id="PROMPT_MAIN_TRUNCATE_LENGTH">PROMPT_MAIN_TRUNCATE_LENGTH
          <dd><p>Note: instance and index assignment expressions could also be written like: “foo.bar=(1)” and “foo.[]=(1, bar)”, when expressed that way, the former be parsed as :assign and echo will be suppressed, but the latter is parsed as a :method_add_arg and the output won’t be suppressed</p>
          <dt id="PROMPT_MAIN_TRUNCATE_OMISSION">PROMPT_MAIN_TRUNCATE_OMISSION
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-context" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">context</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the current context of this irb session</p>
              </div>
            </div>
          <div id="attribute-i-scanner" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">scanner</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>The lexer used by this irb session</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(workspace = nil, input_method = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new irb session</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File irb.rb, line 435</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">workspace</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">input_method</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@context</span> = <span class="ruby-constant">Context</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>, <span class="ruby-identifier">workspace</span>, <span class="ruby-identifier">input_method</span>)
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span>.<span class="ruby-identifier">load_commands_to_main</span>
  <span class="ruby-ivar">@signal_status</span> = <span class="ruby-value">:IN_IRB</span>
  <span class="ruby-ivar">@scanner</span> = <span class="ruby-constant">RubyLex</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@context</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build_statement" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_statement</span><span
                                class="method-args">(code)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_statement-source">
            <pre><span class="ruby-comment"># File irb.rb, line 635</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_statement</span>(<span class="ruby-identifier">code</span>)
  <span class="ruby-identifier">code</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">encoding</span>)
  <span class="ruby-identifier">command_or_alias</span>, <span class="ruby-identifier">arg</span> = <span class="ruby-identifier">code</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s/</span>, <span class="ruby-value">2</span>)
  <span class="ruby-comment"># Transform a non-identifier alias (@, $) or keywords (next, break)</span>
  <span class="ruby-identifier">command_name</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">command_aliases</span>[<span class="ruby-identifier">command_or_alias</span>.<span class="ruby-identifier">to_sym</span>]
  <span class="ruby-identifier">command</span> = <span class="ruby-identifier">command_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">command_or_alias</span>
  <span class="ruby-identifier">command_class</span> = <span class="ruby-constant">ExtendCommandBundle</span>.<span class="ruby-identifier">load_command</span>(<span class="ruby-identifier">command</span>)

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">command_class</span>
    <span class="ruby-constant">Statement</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">code</span>, <span class="ruby-identifier">command</span>, <span class="ruby-identifier">arg</span>, <span class="ruby-identifier">command_class</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">Statement</span><span class="ruby-operator">::</span><span class="ruby-constant">Expression</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">code</span>, <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">assignment_expression?</span>(<span class="ruby-identifier">code</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-configure_io" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">configure_io</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="configure_io-source">
            <pre><span class="ruby-comment"># File irb.rb, line 655</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">configure_io</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:check_termination</span>)
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">check_termination</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">code</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-constant">Reline</span><span class="ruby-operator">::</span><span class="ruby-constant">IOGate</span>.<span class="ruby-identifier">in_pasting?</span>
        <span class="ruby-identifier">rest</span> = <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">check_termination_in_prev_line</span>(<span class="ruby-identifier">code</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">rest</span>
          <span class="ruby-constant">Reline</span>.<span class="ruby-identifier">delete_text</span>
          <span class="ruby-identifier">rest</span>.<span class="ruby-identifier">bytes</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
            <span class="ruby-constant">Reline</span>.<span class="ruby-identifier">ungetc</span>(<span class="ruby-identifier">c</span>)
          <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">true</span>
        <span class="ruby-keyword">else</span>
          <span class="ruby-keyword">false</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-comment"># Accept any single-line input for symbol aliases or commands that transform args</span>
        <span class="ruby-keyword">next</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">single_line_command?</span>(<span class="ruby-identifier">code</span>)

        <span class="ruby-identifier">_tokens</span>, <span class="ruby-identifier">_opens</span>, <span class="ruby-identifier">terminated</span> = <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">check_code_state</span>(<span class="ruby-identifier">code</span>)
        <span class="ruby-identifier">terminated</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:dynamic_prompt</span>)
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">dynamic_prompt</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lines</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">tokens</span> = <span class="ruby-constant">RubyLex</span>.<span class="ruby-identifier">ripper_lex_without_warning</span>(<span class="ruby-identifier">lines</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> }.<span class="ruby-identifier">join</span>, <span class="ruby-value">context:</span> <span class="ruby-ivar">@context</span>)
      <span class="ruby-identifier">line_results</span> = <span class="ruby-constant">IRB</span><span class="ruby-operator">::</span><span class="ruby-constant">NestingParser</span>.<span class="ruby-identifier">parse_by_line</span>(<span class="ruby-identifier">tokens</span>)
      <span class="ruby-identifier">tokens_until_line</span> = []
      <span class="ruby-identifier">line_results</span>.<span class="ruby-identifier">map</span>.<span class="ruby-identifier">with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span>(<span class="ruby-identifier">line_tokens</span>, <span class="ruby-identifier">_prev_opens</span>, <span class="ruby-identifier">next_opens</span>, <span class="ruby-identifier">_min_depth</span>), <span class="ruby-identifier">line_num_offset</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">line_tokens</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">token</span>, <span class="ruby-identifier">_s</span><span class="ruby-operator">|</span>
          <span class="ruby-comment"># Avoid appending duplicated token. Tokens that include &quot;\n&quot; like multiline tstring_content can exist in multiple lines.</span>
          <span class="ruby-identifier">tokens_until_line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">token</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">token</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">tokens_until_line</span>.<span class="ruby-identifier">last</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">continue</span> = <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">should_continue?</span>(<span class="ruby-identifier">tokens_until_line</span>)
        <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">prompt</span>(<span class="ruby-identifier">next_opens</span>, <span class="ruby-identifier">continue</span>, <span class="ruby-identifier">line_num_offset</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:auto_indent</span>) <span class="ruby-keyword">and</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">auto_indent_mode</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">auto_indent</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">lines</span>, <span class="ruby-identifier">line_index</span>, <span class="ruby-identifier">byte_pointer</span>, <span class="ruby-identifier">is_newline</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">lines</span> <span class="ruby-operator">==</span> [<span class="ruby-keyword">nil</span>] <span class="ruby-comment"># Workaround for exit IRB with CTRL+d</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">is_newline</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">lines</span>[<span class="ruby-identifier">line_index</span>]&amp;.<span class="ruby-identifier">byteslice</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">byte_pointer</span>)&amp;.<span class="ruby-identifier">match?</span>(<span class="ruby-regexp">/\A\s*\z/</span>)

      <span class="ruby-identifier">code</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">line_index</span>].<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;#{l}\n&quot;</span> }.<span class="ruby-identifier">join</span>
      <span class="ruby-identifier">tokens</span> = <span class="ruby-constant">RubyLex</span>.<span class="ruby-identifier">ripper_lex_without_warning</span>(<span class="ruby-identifier">code</span>, <span class="ruby-value">context:</span> <span class="ruby-ivar">@context</span>)
      <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">process_indent_level</span>(<span class="ruby-identifier">tokens</span>, <span class="ruby-identifier">lines</span>, <span class="ruby-identifier">line_index</span>, <span class="ruby-identifier">is_newline</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-convert_invalid_byte_sequence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">convert_invalid_byte_sequence</span><span
                                class="method-args">(str, enc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="convert_invalid_byte_sequence-source">
            <pre><span class="ruby-comment"># File irb.rb, line 707</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">convert_invalid_byte_sequence</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">scrub</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">bytes</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;\\x#{b.to_s(16).upcase}&quot;</span> }.<span class="ruby-identifier">join</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug_break" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug_break</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>A hook point for ‘debug` command’s breakpoint after :IRB_EXIT as well as its clean-up</p>

                              <div class="method-source-code" id="debug_break-source">
            <pre><span class="ruby-comment"># File irb.rb, line 443</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug_break</span>
  <span class="ruby-comment"># it means the debug integration has been activated</span>
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">defined?</span>(<span class="ruby-constant">DEBUGGER__</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">DEBUGGER__</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:capture_frames_without_irb</span>)
    <span class="ruby-comment"># after leaving this initial breakpoint, revert the capture_frames patch</span>
    <span class="ruby-constant">DEBUGGER__</span>.<span class="ruby-identifier">singleton_class</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:alias_method</span>, <span class="ruby-value">:capture_frames</span>, <span class="ruby-value">:capture_frames_without_irb</span>)
    <span class="ruby-comment"># and remove the redundant method</span>
    <span class="ruby-constant">DEBUGGER__</span>.<span class="ruby-identifier">singleton_class</span>.<span class="ruby-identifier">send</span>(<span class="ruby-value">:undef_method</span>, <span class="ruby-value">:capture_frames_without_irb</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug_readline" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug_readline</span><span
                                class="method-args">(binding)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="debug_readline-source">
            <pre><span class="ruby-comment"># File irb.rb, line 453</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug_readline</span>(<span class="ruby-identifier">binding</span>)
  <span class="ruby-identifier">workspace</span> = <span class="ruby-constant">IRB</span><span class="ruby-operator">::</span><span class="ruby-constant">WorkSpace</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">binding</span>)
  <span class="ruby-identifier">context</span>.<span class="ruby-identifier">workspace</span> = <span class="ruby-identifier">workspace</span>
  <span class="ruby-identifier">context</span>.<span class="ruby-identifier">workspace</span>.<span class="ruby-identifier">load_commands_to_main</span>
  <span class="ruby-identifier">scanner</span>.<span class="ruby-identifier">increase_line_no</span>(<span class="ruby-value">1</span>)

  <span class="ruby-comment"># When users run:</span>
  <span class="ruby-comment"># 1. Debugging commands, like `step 2`</span>
  <span class="ruby-comment"># 2. Any input that&#39;s not irb-command, like `foo = 123`</span>
  <span class="ruby-comment">#</span>
  <span class="ruby-comment"># Irb#eval_input will simply return the input, and we need to pass it to the debugger.</span>
  <span class="ruby-identifier">input</span> = <span class="ruby-keyword">if</span> <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">conf</span>[<span class="ruby-value">:SAVE_HISTORY</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">support_history_saving?</span>
    <span class="ruby-comment"># Previous IRB session&#39;s history has been saved when `Irb#run` is exited</span>
    <span class="ruby-comment"># We need to make sure the saved history is not saved again by reseting the counter</span>
    <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">reset_history_counter</span>

    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">eval_input</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">save_history</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">eval_input</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">input</span>&amp;.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&quot;\n&quot;</span>)
    <span class="ruby-identifier">scanner</span>.<span class="ruby-identifier">increase_line_no</span>(<span class="ruby-identifier">input</span>.<span class="ruby-identifier">count</span>(<span class="ruby-string">&quot;\n&quot;</span>) <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">input</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each_top_level_statement" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_top_level_statement</span><span
                                class="method-args">() { |build_statement(code), line_no| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="each_top_level_statement-source">
            <pre><span class="ruby-comment"># File irb.rb, line 622</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_top_level_statement</span>
  <span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">code</span> = <span class="ruby-identifier">readmultiline</span>
    <span class="ruby-keyword">break</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">code</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">code</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;\n&quot;</span>
      <span class="ruby-keyword">yield</span> <span class="ruby-identifier">build_statement</span>(<span class="ruby-identifier">code</span>), <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">line_no</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">increase_line_no</span>(<span class="ruby-identifier">code</span>.<span class="ruby-identifier">count</span>(<span class="ruby-string">&quot;\n&quot;</span>))
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">RubyLex</span><span class="ruby-operator">::</span><span class="ruby-constant">TerminateLineInput</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-encode_with_invalid_byte_sequence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_with_invalid_byte_sequence</span><span
                                class="method-args">(str, enc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="encode_with_invalid_byte_sequence-source">
            <pre><span class="ruby-comment"># File irb.rb, line 714</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">encode_with_invalid_byte_sequence</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">conv</span> = <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">Converter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>, <span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">dst</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">conv</span>.<span class="ruby-identifier">primitive_convert</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">dst</span>)
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">ret</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:invalid_byte_sequence</span>
      <span class="ruby-identifier">conv</span>.<span class="ruby-identifier">insert_output</span>(<span class="ruby-identifier">conv</span>.<span class="ruby-identifier">primitive_errinfo</span>[<span class="ruby-value">3</span>].<span class="ruby-identifier">dump</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>])
      <span class="ruby-keyword">redo</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:undefined_conversion</span>
      <span class="ruby-identifier">c</span> = <span class="ruby-identifier">conv</span>.<span class="ruby-identifier">primitive_errinfo</span>[<span class="ruby-value">3</span>].<span class="ruby-identifier">dup</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">conv</span>.<span class="ruby-identifier">primitive_errinfo</span>[<span class="ruby-value">1</span>])
      <span class="ruby-identifier">conv</span>.<span class="ruby-identifier">insert_output</span>(<span class="ruby-identifier">c</span>.<span class="ruby-identifier">dump</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>])
      <span class="ruby-keyword">redo</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:incomplete_input</span>
      <span class="ruby-identifier">conv</span>.<span class="ruby-identifier">insert_output</span>(<span class="ruby-identifier">conv</span>.<span class="ruby-identifier">primitive_errinfo</span>[<span class="ruby-value">3</span>].<span class="ruby-identifier">dump</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>])
    <span class="ruby-keyword">when</span> <span class="ruby-value">:finished</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">break</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">while</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">dst</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eval_input" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">eval_input</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates input for this session.</p>

                              <div class="method-source-code" id="eval_input-source">
            <pre><span class="ruby-comment"># File irb.rb, line 517</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">eval_input</span>
  <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">set_prompt</span> <span class="ruby-keyword">do</span>
    <span class="ruby-operator">|</span><span class="ruby-identifier">ltype</span>, <span class="ruby-identifier">indent</span>, <span class="ruby-identifier">continue</span>, <span class="ruby-identifier">line_no</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">ltype</span>
      <span class="ruby-identifier">f</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompt_s</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">continue</span>
      <span class="ruby-identifier">f</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompt_c</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">f</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompt_i</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">f</span> = <span class="ruby-string">&quot;&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">f</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompting?</span>
      <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">prompt</span> = <span class="ruby-identifier">p</span> = <span class="ruby-identifier">prompt</span>(<span class="ruby-identifier">f</span>, <span class="ruby-identifier">ltype</span>, <span class="ruby-identifier">indent</span>, <span class="ruby-identifier">line_no</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">prompt</span> = <span class="ruby-identifier">p</span> = <span class="ruby-string">&quot;&quot;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">auto_indent_mode</span> <span class="ruby-keyword">and</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:auto_indent</span>)
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ltype</span>
        <span class="ruby-identifier">prompt_i</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompt_i</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompt_i</span>
        <span class="ruby-identifier">ind</span> = <span class="ruby-identifier">prompt</span>(<span class="ruby-identifier">prompt_i</span>, <span class="ruby-identifier">ltype</span>, <span class="ruby-identifier">indent</span>, <span class="ruby-identifier">line_no</span>)[<span class="ruby-regexp">/.*\z/</span>].<span class="ruby-identifier">size</span> <span class="ruby-operator">+</span>
          <span class="ruby-identifier">indent</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">size</span>
        <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">prompt</span> = <span class="ruby-identifier">p</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">ind</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">ind</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">prompt</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">configure_io</span>

  <span class="ruby-identifier">each_top_level_statement</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">statement</span>, <span class="ruby-identifier">line_no</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">signal_status</span>(<span class="ruby-value">:IN_EVAL</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-keyword">begin</span>
        <span class="ruby-comment"># If the integration with debugger is activated, we return certain input if it should be dealt with by debugger</span>
        <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">with_debugger</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">should_be_handled_by_debugger?</span>
          <span class="ruby-keyword">return</span> <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">code</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">evaluate</span>(<span class="ruby-identifier">statement</span>.<span class="ruby-identifier">evaluable_code</span>, <span class="ruby-identifier">line_no</span>)

        <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">echo?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">statement</span>.<span class="ruby-identifier">suppresses_echo?</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">is_assignment?</span>
            <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">echo_on_assignment?</span>
              <span class="ruby-identifier">output_value</span>(<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">echo_on_assignment?</span> <span class="ruby-operator">==</span> <span class="ruby-value">:truncate</span>)
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-identifier">output_value</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemExit</span>, <span class="ruby-constant">SignalException</span>
        <span class="ruby-identifier">raise</span>
      <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Interrupt</span>, <span class="ruby-constant">Exception</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">exc</span>
        <span class="ruby-identifier">handle_exception</span>(<span class="ruby-identifier">exc</span>)
        <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span>.<span class="ruby-identifier">local_variable_set</span>(<span class="ruby-value">:_</span>, <span class="ruby-identifier">exc</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-handle_exception" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">handle_exception</span><span
                                class="method-args">(exc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="handle_exception-source">
            <pre><span class="ruby-comment"># File irb.rb, line 736</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">handle_exception</span>(<span class="ruby-identifier">exc</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">backtrace</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">backtrace</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/\/irb(2)?(\/.*|-.*|\.rb)?:/</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">!~</span> <span class="ruby-regexp">/^IRB/</span> <span class="ruby-operator">&amp;&amp;</span>
     <span class="ruby-operator">!</span>(<span class="ruby-constant">SyntaxError</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">exc</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span>(<span class="ruby-constant">EncodingError</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">exc</span>)
    <span class="ruby-comment"># The backtrace of invalid encoding hash (ex. {&quot;\xAE&quot;: 1}) raises EncodingError without lineno.</span>
    <span class="ruby-identifier">irb_bug</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">irb_bug</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">backtrace</span>
    <span class="ruby-identifier">order</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">RUBY_VERSION</span> <span class="ruby-operator">&lt;</span> <span class="ruby-string">&#39;3.0.0&#39;</span>
      <span class="ruby-keyword">if</span> <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">tty?</span>
        <span class="ruby-identifier">message</span> = <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">full_message</span>(<span class="ruby-value">order:</span> <span class="ruby-value">:bottom</span>)
        <span class="ruby-identifier">order</span> = <span class="ruby-value">:bottom</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">message</span> = <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">full_message</span>(<span class="ruby-value">order:</span> <span class="ruby-value">:top</span>)
        <span class="ruby-identifier">order</span> = <span class="ruby-value">:top</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span> <span class="ruby-comment"># &#39;3.0.0&#39; &lt;= RUBY_VERSION</span>
      <span class="ruby-identifier">message</span> = <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">full_message</span>(<span class="ruby-value">order:</span> <span class="ruby-value">:top</span>)
      <span class="ruby-identifier">order</span> = <span class="ruby-value">:top</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">message</span> = <span class="ruby-identifier">convert_invalid_byte_sequence</span>(<span class="ruby-identifier">message</span>, <span class="ruby-identifier">exc</span>.<span class="ruby-identifier">message</span>.<span class="ruby-identifier">encoding</span>)
    <span class="ruby-identifier">message</span> = <span class="ruby-identifier">encode_with_invalid_byte_sequence</span>(<span class="ruby-identifier">message</span>, <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">conf</span>[<span class="ruby-value">:LC_MESSAGES</span>].<span class="ruby-identifier">encoding</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">message</span>.<span class="ruby-identifier">encoding</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">casecmp?</span>(<span class="ruby-constant">IRB</span>.<span class="ruby-identifier">conf</span>[<span class="ruby-value">:LC_MESSAGES</span>].<span class="ruby-identifier">encoding</span>.<span class="ruby-identifier">to_s</span>)
    <span class="ruby-identifier">message</span> = <span class="ruby-identifier">message</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/((?:^\t.+$\n)+)/</span>)  { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">order</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:top</span>
        <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\n&quot;</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-value">:bottom</span>
        <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\n&quot;</span>).<span class="ruby-identifier">reverse</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">irb_bug</span>
        <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span>.<span class="ruby-identifier">filter_backtrace</span>(<span class="ruby-identifier">l</span>) }.<span class="ruby-identifier">compact</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">back_trace_limit</span>
          <span class="ruby-identifier">omit</span> = <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">back_trace_limit</span>
          <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">lines</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span>(<span class="ruby-ivar">@context</span>.<span class="ruby-identifier">back_trace_limit</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>)]
          <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\t... %d levels...&quot;</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">omit</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">reverse</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">order</span> <span class="ruby-operator">==</span> <span class="ruby-value">:bottom</span>
      <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">map</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;\n&quot;</span> }.<span class="ruby-identifier">join</span>
    }
    <span class="ruby-comment"># The &quot;&lt;top (required)&gt;&quot; in &quot;(irb)&quot; may be the top level of IRB so imitate the main object.</span>
    <span class="ruby-identifier">message</span> = <span class="ruby-identifier">message</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\(irb\):(?&lt;num&gt;\d+):in `&lt;(?&lt;frame&gt;top \(required\))&gt;&#39;/</span>)  { <span class="ruby-node">&quot;(irb):#{$~[:num]}:in `&lt;main&gt;&#39;&quot;</span> }
    <span class="ruby-identifier">puts</span> <span class="ruby-identifier">message</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;Maybe IRB bug!\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">irb_bug</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Outputs the local variables to this current session, including <a href="Irb.html#method-i-signal_status"><code>signal_status</code></a> and <a href="Irb.html#attribute-i-context"><code>context</code></a>, using <a href="Locale.html"><code>IRB::Locale</code></a>.</p>

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File irb.rb, line 962</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-identifier">ary</span> = []
  <span class="ruby-keyword">for</span> <span class="ruby-identifier">iv</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">instance_variables</span>
    <span class="ruby-keyword">case</span> (<span class="ruby-identifier">iv</span> = <span class="ruby-identifier">iv</span>.<span class="ruby-identifier">to_s</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;@signal_status&quot;</span>
      <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;%s=:%s&quot;</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-ivar">@signal_status</span>.<span class="ruby-identifier">id2name</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-string">&quot;@context&quot;</span>
      <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;%s=%s&quot;</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">iv</span>).<span class="ruby-identifier">__to_s__</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;%s=%s&quot;</span>, <span class="ruby-identifier">iv</span>, <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">iv</span>))
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">format</span>(<span class="ruby-string">&quot;#&lt;%s: %s&gt;&quot;</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;, &quot;</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-read_input" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">read_input</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="read_input-source">
            <pre><span class="ruby-comment"># File irb.rb, line 575</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">read_input</span>
  <span class="ruby-identifier">signal_status</span>(<span class="ruby-value">:IN_INPUT</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">l</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">gets</span>
      <span class="ruby-identifier">print</span> <span class="ruby-identifier">l</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">verbose?</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">ignore_eof?</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">readable_after_eof?</span>
        <span class="ruby-identifier">l</span> = <span class="ruby-string">&quot;\n&quot;</span>
        <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">verbose?</span>
          <span class="ruby-identifier">printf</span> <span class="ruby-string">&quot;Use \&quot;exit\&quot; to leave %s\n&quot;</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">ap_name</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">prompting?</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">l</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-readmultiline" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">readmultiline</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="readmultiline-source">
            <pre><span class="ruby-comment"># File irb.rb, line 593</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">readmultiline</span>
  <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">save_prompt_to_context_io</span>([], <span class="ruby-keyword">false</span>, <span class="ruby-value">0</span>)

  <span class="ruby-comment"># multiline</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">read_input</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:check_termination</span>)

  <span class="ruby-comment"># nomultiline</span>
  <span class="ruby-identifier">code</span> = <span class="ruby-string">&#39;&#39;</span>
  <span class="ruby-identifier">line_offset</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">line</span> = <span class="ruby-identifier">read_input</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">line</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">code</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">code</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">code</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>

    <span class="ruby-comment"># Accept any single-line input for symbol aliases or commands that transform args</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">code</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">single_line_command?</span>(<span class="ruby-identifier">code</span>)

    <span class="ruby-identifier">tokens</span>, <span class="ruby-identifier">opens</span>, <span class="ruby-identifier">terminated</span> = <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">check_code_state</span>(<span class="ruby-identifier">code</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">code</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">terminated</span>

    <span class="ruby-identifier">line_offset</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
    <span class="ruby-identifier">continue</span> = <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">should_continue?</span>(<span class="ruby-identifier">tokens</span>)
    <span class="ruby-ivar">@scanner</span>.<span class="ruby-identifier">save_prompt_to_context_io</span>(<span class="ruby-identifier">opens</span>, <span class="ruby-identifier">continue</span>, <span class="ruby-identifier">line_offset</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-run" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">run</span><span
                                class="method-args">(conf = IRB.conf)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="run-source">
            <pre><span class="ruby-comment"># File irb.rb, line 485</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">run</span>(<span class="ruby-identifier">conf</span> = <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">conf</span>)
  <span class="ruby-identifier">in_nested_session</span> = <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-identifier">conf</span>[<span class="ruby-value">:MAIN_CONTEXT</span>]
  <span class="ruby-identifier">conf</span>[<span class="ruby-value">:IRB_RC</span>].<span class="ruby-identifier">call</span>(<span class="ruby-identifier">context</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">conf</span>[<span class="ruby-value">:IRB_RC</span>]
  <span class="ruby-identifier">conf</span>[<span class="ruby-value">:MAIN_CONTEXT</span>] = <span class="ruby-identifier">context</span>

  <span class="ruby-identifier">save_history</span> = <span class="ruby-operator">!</span><span class="ruby-identifier">in_nested_session</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">conf</span>[<span class="ruby-value">:SAVE_HISTORY</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">support_history_saving?</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">save_history</span>
    <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">load_history</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">prev_trap</span> = <span class="ruby-identifier">trap</span>(<span class="ruby-string">&quot;SIGINT&quot;</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">signal_handle</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">catch</span>(<span class="ruby-value">:IRB_EXIT</span>) <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">eval_input</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-identifier">trap</span>(<span class="ruby-string">&quot;SIGINT&quot;</span>, <span class="ruby-identifier">prev_trap</span>)
    <span class="ruby-identifier">conf</span>[<span class="ruby-value">:AT_EXIT</span>].<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">hook</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hook</span>.<span class="ruby-identifier">call</span>}
    <span class="ruby-identifier">context</span>.<span class="ruby-identifier">io</span>.<span class="ruby-identifier">save_history</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">save_history</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-signal_handle" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">signal_handle</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Handler for the signal SIGINT, see Kernel#trap for more information.</p>

                              <div class="method-source-code" id="signal_handle-source">
            <pre><span class="ruby-comment"># File irb.rb, line 842</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">signal_handle</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">ignore_sigint?</span>
    <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;\nabort!\n&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">verbose?</span>
    <span class="ruby-identifier">exit</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">case</span> <span class="ruby-ivar">@signal_status</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">:IN_INPUT</span>
    <span class="ruby-identifier">print</span> <span class="ruby-string">&quot;^C\n&quot;</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">RubyLex</span><span class="ruby-operator">::</span><span class="ruby-constant">TerminateLineInput</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">:IN_EVAL</span>
    <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">irb_abort</span>(<span class="ruby-keyword">self</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-value">:IN_LOAD</span>
    <span class="ruby-constant">IRB</span>.<span class="ruby-identifier">irb_abort</span>(<span class="ruby-keyword">self</span>, <span class="ruby-constant">LoadAbort</span>)
  <span class="ruby-keyword">when</span> <span class="ruby-value">:IN_IRB</span>
    <span class="ruby-comment"># ignore</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># ignore other cases as well</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-signal_status" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">signal_status</span><span
                                class="method-args">(status) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block using the given <code>status</code>.</p>

                              <div class="method-source-code" id="signal_status-source">
            <pre><span class="ruby-comment"># File irb.rb, line 864</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">signal_status</span>(<span class="ruby-identifier">status</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">yield</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@signal_status</span> <span class="ruby-operator">==</span> <span class="ruby-value">:IN_LOAD</span>

  <span class="ruby-identifier">signal_status_back</span> = <span class="ruby-ivar">@signal_status</span>
  <span class="ruby-ivar">@signal_status</span> = <span class="ruby-identifier">status</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@signal_status</span> = <span class="ruby-identifier">signal_status_back</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-single_line_command-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">single_line_command?</span><span
                                class="method-args">(code)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="single_line_command-3F-source">
            <pre><span class="ruby-comment"># File irb.rb, line 650</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">single_line_command?</span>(<span class="ruby-identifier">code</span>)
  <span class="ruby-identifier">command</span> = <span class="ruby-identifier">code</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s/</span>, <span class="ruby-value">2</span>).<span class="ruby-identifier">first</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">symbol_alias?</span>(<span class="ruby-identifier">command</span>) <span class="ruby-operator">||</span> <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">transform_args?</span>(<span class="ruby-identifier">command</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-suspend_context" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">suspend_context</span><span
                                class="method-args">(context) { |back_context| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block using the given <code>context</code> as the <a href="Context.html"><code>Context</code></a>.</p>

                              <div class="method-source-code" id="suspend_context-source">
            <pre><span class="ruby-comment"># File irb.rb, line 832</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">suspend_context</span>(<span class="ruby-identifier">context</span>)
  <span class="ruby-ivar">@context</span>, <span class="ruby-identifier">back_context</span> = <span class="ruby-identifier">context</span>, <span class="ruby-ivar">@context</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">back_context</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@context</span> = <span class="ruby-identifier">back_context</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-suspend_input_method" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">suspend_input_method</span><span
                                class="method-args">(input_method) { |back_io| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block using the given <code>input_method</code> as the <a href="Context.html#attribute-i-io"><code>Context#io</code></a>.</p>

<p>Used by the irb commands <code>source</code> and <code>irb_load</code>, see <a href="../IRB.html#module-IRB-label-IRB+Sessions">IRB Sessions at <code>IRB</code></a> for more information.</p>

                              <div class="method-source-code" id="suspend_input_method-source">
            <pre><span class="ruby-comment"># File irb.rb, line 821</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">suspend_input_method</span>(<span class="ruby-identifier">input_method</span>)
  <span class="ruby-identifier">back_io</span> = <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">io</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">instance_eval</span>{<span class="ruby-ivar">@io</span> = <span class="ruby-identifier">input_method</span>}
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">back_io</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">instance_eval</span>{<span class="ruby-ivar">@io</span> = <span class="ruby-identifier">back_io</span>}
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-suspend_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">suspend_name</span><span
                                class="method-args">(path = nil, name = nil) { |back_path, back_name| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block using the given <code>path</code> as the <a href="Context.html#attribute-i-irb_path"><code>Context#irb_path</code></a> and <code>name</code> as the <a href="Context.html#attribute-i-irb_name"><code>Context#irb_name</code></a>.</p>

<p>Used by the irb command <code>source</code>, see <a href="../IRB.html#module-IRB-label-IRB+Sessions">IRB Sessions at <code>IRB</code></a> for more information.</p>

                              <div class="method-source-code" id="suspend_name-source">
            <pre><span class="ruby-comment"># File irb.rb, line 791</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">suspend_name</span>(<span class="ruby-identifier">path</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_path</span>, <span class="ruby-identifier">back_path</span> = <span class="ruby-identifier">path</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_name</span>, <span class="ruby-identifier">back_name</span> = <span class="ruby-identifier">name</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">back_path</span>, <span class="ruby-identifier">back_name</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_path</span> = <span class="ruby-identifier">back_path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">irb_name</span> = <span class="ruby-identifier">back_name</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-suspend_workspace" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">suspend_workspace</span><span
                                class="method-args">(workspace) { |back_workspace| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Evaluates the given block using the given <code>workspace</code> as the <a href="Context.html#attribute-i-workspace"><code>Context#workspace</code></a>.</p>

<p>Used by the irb command <code>irb_load</code>, see <a href="../IRB.html#module-IRB-label-IRB+Sessions">IRB Sessions at <code>IRB</code></a> for more information.</p>

                              <div class="method-source-code" id="suspend_workspace-source">
            <pre><span class="ruby-comment"># File irb.rb, line 807</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">suspend_workspace</span>(<span class="ruby-identifier">workspace</span>)
  <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span>, <span class="ruby-identifier">back_workspace</span> = <span class="ruby-identifier">workspace</span>, <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span> <span class="ruby-identifier">back_workspace</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-ivar">@context</span>.<span class="ruby-identifier">workspace</span> = <span class="ruby-identifier">back_workspace</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

